//
//  ByHomeEventCell.m
//  caipiao_ios
//
//  Created by mc on 2018/7/7.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByHomeEventCell.h"
#import "ByHomeEventView.h"

@implementation ByHomeEventCell

+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByHomeEventCell";
    ByHomeEventCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self initViews];
    }
    return self;
}


- (void)initViews{
    [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    
    self.contentView.backgroundColor = BY_BACKGROUND_COLOR;
    UIView *backgroundView = [[UIView alloc] init];
    [self.contentView addSubview:backgroundView];
    [backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
        make.top.equalTo(self.contentView).offset(5);
        make.bottom.equalTo(self.contentView).offset(-5);
    }];
    backgroundView.layer.cornerRadius = 5;
    backgroundView.layer.masksToBounds = YES;
    backgroundView.backgroundColor = [UIColor whiteColor];
    
    
    UIButton *bettingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backgroundView addSubview:bettingBtn];
    [bettingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(backgroundView).offset(-5);
        make.bottom.equalTo(backgroundView).offset(-5);
        make.size.mas_equalTo(CGSizeMake(80, 25));
    }];
    [bettingBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [bettingBtn setTitle:@"立即投注" forState:UIControlStateNormal];
    bettingBtn.backgroundColor = BY_THEME_COLOR;
    bettingBtn.titleLabel.font = FONT(12);
    bettingBtn.layer.cornerRadius = 5;
    
    
    
    ByHomeEventView *leftView = [[ByHomeEventView alloc] init];
    [self.contentView addSubview:leftView];
    [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(0);
        make.left.equalTo(self.contentView).offset(20);
        make.size.mas_equalTo(CGSizeMake(100, 120));
    }];
    
    ByHomeEventView *rightView = [[ByHomeEventView alloc] init];
    [self.contentView addSubview:rightView];
    [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(0);
        make.right.equalTo(self.contentView).offset(-20);
        make.size.mas_equalTo(CGSizeMake(100, 120));
    }];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    [backgroundView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backgroundView).offset(20);
        make.left.equalTo(leftView.mas_right).offset(10);
        make.right.equalTo(rightView.mas_left).offset(-10);
        make.height.mas_equalTo(@15);
    }];
    
    titleLabel.font = FONT(14);
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"标题";
    
    
    
    UILabel *timeLabel = [[UILabel alloc] init];
    [backgroundView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel.mas_left).offset(0);
        make.right.equalTo(titleLabel.mas_right).offset(0);
        make.height.mas_equalTo(@15);
        make.top.equalTo(titleLabel.mas_bottom).offset(5);
    }];
    timeLabel.textColor = [UIColor lightGrayColor];
    timeLabel.font = FONT(12);
    timeLabel.text = @"截止今天17:00";
    timeLabel.textAlignment = NSTextAlignmentCenter;
    
    
    UILabel *moneyLabel = [[UILabel alloc] init];
    [backgroundView addSubview:moneyLabel];
    [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backgroundView).offset(10);
        make.centerY.equalTo(bettingBtn.mas_centerY).offset(0);
        make.size.mas_equalTo(CGSizeMake(120, 15));
    }];
    moneyLabel.text = @"投注金额：50元";
    moneyLabel.font = FONT(12);
    moneyLabel.textColor = BY_TEXT_COLOR;
    
}




@end
